<template>
  <div class="input-box">
    <span  :style="dispan">{{text1}}</span>
    <input :type="type" :disabled="disabled" :placeholder="text2" v-model="value"  ref="input"/>
      <img src="../assets/清除.png" class="input_check" @click="Valueclear" :style="Valuecheck"/>
    
  </div>
</template>

<script>
export default {
  name: "w-input",
  data() {
    return {
      value: ""
    };
  },
  props: {
    text1: {
      type: String,
      default: ""
    },
    text2: {
      type: String,
      default: ""
    },
    type: {
      type: String,
      default: "type"
    },
    disabled: {
      type: Boolean,
      default: false
    }
  },
  watch: {
    
  },
  computed: {
    dispan() {
      let dispan = {};
      if (this.text1 === "") {
        dispan["display"] = "none";
      } else {
        dispan["margin-right"] = "10px";
      }
    },
    Valuecheck() {
      let checkstyle = {};
      if (this.value != "") {
        checkstyle["width"] = "25px";
      }
      else{
        checkstyle["width"] = "0px";
      }
      return checkstyle;
    }
  },
  methods: {
    Valueclear(){
      this.value="";
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.input-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-bottom: 5px;
  padding-top: 5px;
  width: 100%;
}
input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 0px solid #dcdfe6;
  border-bottom: 1px solid #dcdfe6;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  -webkit-transition: border-bottom 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  transition: border-bottom 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  font-size: 16px;
}
input:focus {
  outline: none;
  border-bottom: 2px solid #409eff;
  caret-color: #409eff;
}
input:disabled {
  color: rgb(84, 84, 84);
  cursor: default;
}
.input_check {
  display: flex;
  position: absolute;
  height: 25px;
  right: 0px;
}
</style>
